home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-29 | 1.2 KB | 38 lines | [TEXT/MPS ] |
- # InsertFile - script to insert text from a chosen file into the current window
-
- Set FName `Begin; NewGetFile -b "Insert" -t TEXT -r; Set GetStatus {Status}; End`
- If ({GetStatus} == 0)
- # no errors or cancellation
- If ("{FName}" == "{Active}")
- # files to be inserted from and to are the same!
- Alert "{0}:∂nSorry, you cannot insert text from a file into itself."
- Else
- # test if the source file is already open
- Set NoClose 0
- For i in `Windows`
- If "{i}" == "{FName}"
- Set NoClose 1
- Break
- End # If {i}
- End # For i
- Set OldActive "{Active}"
- If ({NoClose} == 0)
- Open -r "{FName}" # display the source window (as read-only)
- Else
- Open "{FName}" # make the source window frontmost
- End # If {NoClose }
- If ({Status} == 0)
- # no errors
- Target "{OldActive}" # make the old active window the target (window updates that slow the process don't occur in target window
- TypeFile "{FName}" > "{Target}".§ # transfer the text
- Open "{OldActive}" # restore the old active window
- If ({NoClose} == 0)
- Close -n "{FName}" # close the source window
- End # If {NoClose}
- Else
- Alert "{0}:∂nUnable to open the file {FName}"
- End # If {Status}
- End # If {FName}
- End # If {SaveStatus}
-
- # end of InsertFile